﻿using DevExpress.XtraGrid;
using DoAnQuamLy.DataAccess;
using DoAnQuamLy.Object;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace DoAnQuamLy.Controller
{
    class ThongKeAnUongController
    {
        ThongKeAnUongData data = new ThongKeAnUongData();
        public void SapXepDuLieuLenfromThongKedo_an_uong(GridControl dgv)
        {

            BindingSource bs = new BindingSource();
            bs.DataSource = data.Thongke_an_uong();
            dgv.DataSource = bs;
        }

        public List<ThongKeAnUongObject> DangKy()
        {
            List<ThongKeAnUongObject> DK = new List<ThongKeAnUongObject>();
            DataTable dt = data.Thongke_an_uong();
            int k = dt.Rows.Count;
            for (int i = 0; i < k; i++)
            {
                ThongKeAnUongObject ok = new ThongKeAnUongObject();
                ok.MatHang = dt.Rows[i]["Mathang"].ToString();
                ok.SoLuong = Convert.ToInt32(dt.Rows[i]["Soluong"].ToString());
                ok.DVT = dt.Rows[i]["DVT"].ToString();
                ok.GiaBan = Convert.ToInt32(dt.Rows[i]["Giaban"].ToString());
                ok.TienBan = Convert.ToInt32(dt.Rows[i]["Tienban"].ToString());
                ok.GiaNhap = Convert.ToInt32(dt.Rows[i]["Gianhap"].ToString());
                ok.TienNhap = Convert.ToInt32(dt.Rows[i]["Tiennhap"].ToString());
                ok.Lai = Convert.ToInt32(dt.Rows[i]["Lai"].ToString());
                ok.PhanTramDoanhThu = Convert.ToInt32(dt.Rows[i]["PhantramDoanhthu"].ToString());
                DK.Add(ok);
            }
            return DK;
        }
        public void Update()
        {
            data.Update();
        }
    }
}
